package com.matt.foundation.vo.observation;

import com.matt.domain.observation.ObservationNew;
import com.matt.domain.observation.ObservationNewOption;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/8/14
 * *******************************
 */
@Data
public class ObservationNewVo {
    private String id;

    private String question;

    private String typeName;

    private Integer typeCode;
    
    private Integer multiSelect;

    private List<ObservationNewOptionVo> options;

    public static ObservationNewVo of(ObservationNew observation, List<ObservationNewOption> options){
        ObservationNewVo vo = new ObservationNewVo();
        vo.setId(observation.getId());
        vo.setQuestion(observation.getQuestion());
        vo.setTypeName(observation.getTypeName());
        vo.setTypeCode(observation.getTypeCode());
        vo.setMultiSelect(observation.getMultiSelect());
       
        List<ObservationNewOptionVo> voList = options.stream().map(o->ObservationNewOptionVo.of(o)).collect(Collectors.toList());
        vo.setOptions(voList);
        return vo;
    }
}
